<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-2"></span><span>
</span><span id="line-3"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-4"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- Module      :  Data.Ix</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow 2001</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- License     :  BSD-style (see the file libraries/base/LICENSE)</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- </span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Stability   :  stable</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-12"></span><span class="hs-comment">--</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- The 'Ix' class is used to map a contiguous subrange of values in</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- type onto integers.  It is used primarily for array indexing</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- (see the array package).  'Ix' uses row-major order.</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- </span><span>
</span><span id="line-17"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Data.Ix</span><span>
</span><span id="line-20"></span><span>    </span><span class="hs-special">(</span><span>
</span><span id="line-21"></span><span>    </span><span class="annot"><span class="hs-comment">-- * The 'Ix' class</span></span><span>
</span><span id="line-22"></span><span>        </span><span class="annot"><a href="GHC.Ix.html#Ix"><span class="hs-identifier">Ix</span></a></span><span>
</span><span id="line-23"></span><span>          </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Ix.html#range"><span class="hs-identifier">range</span></a></span><span>
</span><span id="line-24"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Ix.html#index"><span class="hs-identifier">index</span></a></span><span>
</span><span id="line-25"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Ix.html#inRange"><span class="hs-identifier">inRange</span></a></span><span>
</span><span id="line-26"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Ix.html#rangeSize"><span class="hs-identifier">rangeSize</span></a></span><span>
</span><span id="line-27"></span><span>          </span><span class="hs-special">)</span><span>
</span><span id="line-28"></span><span>    </span><span class="hs-comment">-- Ix instances:</span><span>
</span><span id="line-29"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-30"></span><span>    </span><span class="hs-comment">--  Ix Char</span><span>
</span><span id="line-31"></span><span>    </span><span class="hs-comment">--  Ix Int</span><span>
</span><span id="line-32"></span><span>    </span><span class="hs-comment">--  Ix Integer</span><span>
</span><span id="line-33"></span><span>    </span><span class="hs-comment">--  Ix Bool</span><span>
</span><span id="line-34"></span><span>    </span><span class="hs-comment">--  Ix Ordering</span><span>
</span><span id="line-35"></span><span>    </span><span class="hs-comment">--  Ix ()</span><span>
</span><span id="line-36"></span><span>    </span><span class="hs-comment">--  (Ix a, Ix b) =&gt; Ix (a, b)</span><span>
</span><span id="line-37"></span><span>    </span><span class="hs-comment">--  ...</span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Deriving Instances of 'Ix'</span></span><span>
</span><span id="line-40"></span><span>    </span><span class="hs-comment">-- | Derived instance declarations for the class 'Ix' are only possible</span><span>
</span><span id="line-41"></span><span>    </span><span class="hs-comment">-- for enumerations (i.e. datatypes having only nullary constructors)</span><span>
</span><span id="line-42"></span><span>    </span><span class="hs-comment">-- and single-constructor datatypes, including arbitrarily large tuples,</span><span>
</span><span id="line-43"></span><span>    </span><span class="hs-comment">-- whose constituent types are instances of 'Ix'. </span><span>
</span><span id="line-44"></span><span>    </span><span class="hs-comment">-- </span><span>
</span><span id="line-45"></span><span>    </span><span class="hs-comment">-- * For an enumeration, the nullary constructors are assumed to be</span><span>
</span><span id="line-46"></span><span>    </span><span class="hs-comment">-- numbered left-to-right with the indices being 0 to n-1 inclusive. This</span><span>
</span><span id="line-47"></span><span>    </span><span class="hs-comment">-- is the same numbering defined by the 'Enum' class. For example, given</span><span>
</span><span id="line-48"></span><span>    </span><span class="hs-comment">-- the datatype: </span><span>
</span><span id="line-49"></span><span>    </span><span class="hs-comment">-- </span><span>
</span><span id="line-50"></span><span>    </span><span class="hs-comment">-- &gt;        data Colour = Red | Orange | Yellow | Green | Blue | Indigo | Violet</span><span>
</span><span id="line-51"></span><span>    </span><span class="hs-comment">-- </span><span>
</span><span id="line-52"></span><span>    </span><span class="hs-comment">-- we would have: </span><span>
</span><span id="line-53"></span><span>    </span><span class="hs-comment">-- </span><span>
</span><span id="line-54"></span><span>    </span><span class="hs-comment">-- &gt;        range   (Yellow,Blue)        ==  [Yellow,Green,Blue]</span><span>
</span><span id="line-55"></span><span>    </span><span class="hs-comment">-- &gt;        index   (Yellow,Blue) Green  ==  1</span><span>
</span><span id="line-56"></span><span>    </span><span class="hs-comment">-- &gt;        inRange (Yellow,Blue) Red    ==  False</span><span>
</span><span id="line-57"></span><span>    </span><span class="hs-comment">-- </span><span>
</span><span id="line-58"></span><span>    </span><span class="hs-comment">-- * For single-constructor datatypes, the derived instance declarations</span><span>
</span><span id="line-59"></span><span>    </span><span class="hs-comment">-- are as shown for tuples in chapter 19, section 2 of the Haskell 2010 report:</span><span>
</span><span id="line-60"></span><span>    </span><span class="hs-comment">-- &lt;https://www.haskell.org/onlinereport/haskell2010/haskellch19.html&gt;.</span><span>
</span><span id="line-61"></span><span>
</span><span id="line-62"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-63"></span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Ix.html"><span class="hs-identifier">GHC.Ix</span></a></span><span>
</span><span id="line-65"></span></pre></body></html>